package com.ctshk.app.scenic.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.AppReq;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.scenic.dto.NoticeDTO;
import com.ctshk.rpc.scenic.dto.app.ScenicProductIndexDTO;
import com.ctshk.rpc.scenic.service.IScenicReservationService;
import com.ctshk.rpc.scenic.service.app.IScenicProductPCService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 *     景点门票PC端 控制器
 * </p>
 * @author 黄先
 */
@RestController
@Api(value = "景点门票PC端控制器", tags = "景点门票PC端控制器")
@RequestMapping("/pc")
public class ScenicProductPCController extends BaseController {
    @DubboReference
    IScenicProductPCService iScenicProductPCService;
    @DubboReference
    IScenicReservationService iScenicReservationService;

    @GetMapping("/selectScenicProductIndex/{cityId}")
    @ApiOperation(value = "查询首页数据", notes = "查询首页数据")
    public Result<ScenicProductIndexDTO> selectScenicProductIndex(@PathVariable("cityId") Long cityId, AppReq appReq){
        return iScenicProductPCService.selectScenicProductIndex(appReq.getChannelId(), cityId);
    }

    @ApiOperation(value = "查询返回总价", notes = "查询返回总价")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "查询返回总价", operDesc = "查询返回总价")
    @GetMapping("/queryAllPrices")
    public Result test(@RequestParam(value = "type", required = false) Integer type,
                       @RequestParam(value = "stocktId", required = false) Long stocktId,
                       @RequestParam(value = "productId", required = false) Long productId,
                       @RequestParam(value = "id", required = false) Long id,
                       @RequestParam(value = "date", required = false) String date) throws Exception {
        LocalDate parse = LocalDate.parse(date);
        return Result.success(iScenicReservationService.queryAllPrices(type, stocktId, productId, id, parse));
    }

    @PostMapping("/queryListByCode")
    @ApiOperation(value = "查询首页通告信息数据", notes = "查询首页通告信息数据")
    public Result<List<NoticeDTO>> queryListByCode(){
        return Result.success(iScenicReservationService.queryListByCode());
    }
}
